package com.cy.ppj.comm.handler;

import com.cy.ppj.comm.exception.MsgException;
import com.cy.ppj.model.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import java.io.IOException;

/**
 * @description:
 * @author: Ocean
 * @create: 2018-06-14 16:52
 **/
@Slf4j
@ControllerAdvice
public class CommExceptionHandler {

    @ExceptionHandler(MsgException.class)
    @ResponseBody
    public Result handler(MsgException msgException) throws IOException {

        return Result.fail(msgException.getMessage(), msgException.getCode(), msgException.getValue());
    }
}
